﻿using System.Collections.Generic;

namespace HeerCards.Helper
{
    public class CardTextHelper
    {
        private static Dictionary<string, string> ValueDic = new Dictionary<string, string>()
        {
            {"{卡池.名称}","{PoolName}" },
            {"{卡池.Name}", "{PoolName}" },
            {"{Pool.Name}", "{PoolName}" },
            {"{卡池.消耗}", "{PoolCost}" },
            {"{卡池.Cost}", "{PoolCost}" },
            {"{Pool.Cost}", "{PoolCost}" },
            {"{卡池.消耗品}", "{PoolCostItem}" },
            {"{卡池.CostItem}","{PoolCostItem}" },
            {"{Pool.CostItem}","{PoolCostItem}"  },
            {"{等级.名称}","{LevelName}"},
            {"{Level.名称}","{LevelName}"},
            {"{Level.Name}","{LevelName}"},
            {"{等级.描述}", "{LevelDesc}" },
            {"{等级.Desc}", "{LevelDesc}"},
            {"{Level.Desc}", "{LevelDesc}"},
            {"{等级.卡片总数}", "{LevelCardCount}" },
            { "{等级.CardCount}", "{LevelCardCount}" },
            {"{Level.CardCount}", "{LevelCardCount}" },
            {"{卡片.名称}", "{CardName}"},
            {"{卡片.Name}", "{CardName}"},
            {"{Card.Name}", "{CardName}"},
            {"{卡片}", "{CardName}"},
            {"{Card}", "{CardName}"},
            {"{卡片.描述}", "{CardDesc}"},
            {"{卡片.Desc}", "{CardDesc}"},
            {"{Card.Desc}", "{CardDesc}"},
            {"{卡片.倍率}", "{CardEx}"},
            {"{卡片.Ex}", "{CardEx}"},
            {"{卡片.UP}", "{CardEx}"},
            {"{Card.EX}", "{CardEx}"},
            {"{Card.UP}", "{CardEx}"},
        };

        public static string getText(HCPool pool, HCLevel level, HCCard card, string text)
        {
            var dic = new Dictionary<string, string>
            {
                {"{PoolName}", pool.PoolName},
                {"{PoolCost}", pool.Cost.ToString()},
                {"{PoolCostItem}", pool.CostItem},
                {"{LevelName}", level.Name},
                {"{LevelDesc}", level.Description},
                {"{LevelCardCount}", level.Cards.Count.ToString()},
                {"{CardName}", card.Name},
                {"{CardDesc}", card.Description},
                {"{CardEx}", card.ExtraProbability.ToString()}
            };
            foreach (var item in ValueDic)
            {
                if (text.Contains(item.Key))
                {
                    text = text.Replace(item.Key, item.Value);
                }
            }
            foreach (var item in dic)
            {
                if (text.Contains(item.Key))
                {
                    text = text.Replace(item.Key, item.Value);
                }
            }
            text = text.Replace("\\r\\n", "\n");
            text = text.Replace("\\n", "\n");

            return text;
        }
    }
}